<?php
namespace app\mqtt\validate;
use think\Validate;
class MqttClientOnline extends Validate {
    //验证字段
    protected $rule = [
        'account_id' => ['require','number'],
        'mqtt_client_id' => ['require','number'],
        'online' => ['require'],
        'last_time' => ['require','number'],
        'token' => ['require'],
        'id' => ['require','number'],
    ];
    //返回消息
    protected $message = [
        'account_id.require' => '账号id必须',
        'account_id.number' => '账号id不是数字',
        'mqtt_client_id.require' => 'mqtt链接id必须',
        'mqtt_client_id.number' => 'mqtt链接id不是数字',
        'online.require' => '在线必须',
        'last_time.require' => '最后在线时间必须',
        'last_time.number' => '最后在线时间不是数字',
        'token.require' => 'token必须',
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
    ];

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['account_id','mqtt_client_id','online','last_time','token']);
    }

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['id','account_id','mqtt_client_id','online','last_time','token']);
    }
}
